package com.greensam.pixelengine.pojo.entity;

import com.greensam.pixelengine.pojo.base.BaseEntity;
import com.greensam.pixelengine.pojo.emuns.SpaceLevelEnum;
import com.greensam.pixelengine.pojo.emuns.SpaceTypeEnum;
import com.greensam.pixelengine.pojo.emuns.converter.SpaceLevelEnumConverter;
import com.greensam.pixelengine.pojo.emuns.converter.SpaceTypeEnumConverter;
import jakarta.persistence.*;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.ColumnDefault;
import org.hibernate.annotations.Comment;

/**
 * @author Ma Chengrui
 * @since 2025/7/31 17:47
 */
@Getter
@Setter
@Entity
@Table(name = "space_info",
        indexes = {
                @Index(name = "idx_create_id", columnList = "create_by"),
                @Index(name = "idx_space_name", columnList = "name"),
                @Index(name = "idx_space_level", columnList = "level"),
        },
        uniqueConstraints = {
                @UniqueConstraint(name = "uk_user_level", columnNames = {"create_by", "type"})
        })
@Comment("空间信息表")
public class SpacePo extends BaseEntity {

    @Column(nullable = false, length = 128)
    @Comment("空间名称")
    private String name;

    @Column(length = 512)
    @Comment("空间描述")
    private String description;

    @Column(nullable = false, length = 10)
    @ColumnDefault("0")
    @Convert(converter = SpaceLevelEnumConverter.class)
    @Comment("空间等级 0-普通版 1-专业版 2-旗舰版")
    private SpaceLevelEnum level;

    @Column(nullable = false, length = 10)
    @Convert(converter = SpaceTypeEnumConverter.class)
    @Comment("空间类型 0-私有 1-团队")
    private SpaceTypeEnum type;

    @ColumnDefault("0")
    @Comment("空间允许存储的图片总大小")
    private Long maxSize;

    @ColumnDefault("0")
    @Comment("空间内已使用的图片总大小")
    private Long totalSize = 0L;

    @ColumnDefault("0")
    @Comment("空间内图片总数")
    private Long totalCount = 0L;

}
